<?php 
namespace app\talbum\controller;
use app\talbum\service\VideoService;
use think\Request;
use think\facade\Log;
/**
 * @title 视频
 * @description 视频
 * @group 时光相册
 */
class Video extends VideoService
{

    /**
     * @title aliyun
     * @description aliyun
     * @author 凌杰
     * @url /talbum/video/alitests
     * @method POST
     * @return code:错误码
     * @return msg:错误消息
     */
    public function alitests(Request $request)
    {
      
      
        $res = $this->alitest();
        return json($res);
    }

        /**
     * @title 文件测试
     * @description 文件测试
     * @author 凌杰
     * @url /talbum/video/filedump
     * @method POST
     * @return code:错误码
     * @return msg:错误消息
     */
    public function filedump(Request $request)
    {
      $file=$_FILES['video'];
      $data['title']=$file['name'];
      $data['file']=$file['name']."mp4";
      $s=$this->alitest($data);
      dump($s); 
    }
    /**
     * @title 获得阿里云视频上传凭证
     * @description 获得阿里云视频上传凭证
     * @author 凌杰
     * @url /talbum/video/get_alivideo_cert
     * @method POST
     * @param name:video type:string require:1 default:"" other: desc:视频文件
     * @param name:videoid type:string require:1 default:"" other: desc:视频文件
     * @return code:错误码
     * @return msg:错误消息
     * @return date:数据列表@
     * @date UploadAddress:UploadAddress VideoId:VideoId RequestId:RequestId UploadAuth:UploadAuth
     */
    public function get_alivideo_cert(Request $request)
    {
        if(!$request->isPost()) return False;
        $info=$request->param();
        $info['video']=$request->file('video');
        $res = $this->alivideo($info);
        return json($res);
    }
   
	/**
     * @title 添加视频
     * @description 添加视频
     * @author 凌杰
     * @url /talbum/video/insert_video
     * @method POST
     * @param name:videoname type:string require:1 default:"" other: desc:视频名称
     * @param name:Openid type:string require:1 default:'' other: desc:为空表示登陆用户自己操作，否则表示当前的Openid用户操作
     * @param name:describe type:string require:1 default:'' other: desc:视频描述permissions
     * @param name:permissions type:string require:1 default:'' other: desc:视频权限1公开，2好友，3自己
     * @param name:videoregion type:string require:1 default:'' other: desc:视频地区
     * @param name:video type:file require:1 default:'' other: desc:视频文件
     * @param name:cover type:file require:1 default:'' other: desc:视频封面图文件
     * @return code:错误码
     * @return msg:错误消息
     */
	public function insert_video(Request $request)
	{
		if(!$request->isPost()) return False;
		$info=$request->param();
        $info['cover']=$request->file('cover');
        $info['video']=$request->file('video');
		$res = $this->insert_videos($info);
		return json($res);
	}
/**
     * @title 视频列表
     * @description 视频列表
     * @author 凌杰
     * @url /talbum/video/video_lists
     * @method POST
     * @param name:page type:int require:0 default:"" other: desc:页数
     * @param name:limit type:int require:0 default:'' other: desc:每页条数
     * @param name:Openid type:string require:1 default:'' other: desc:为空表示登陆用户自己操作，否则表示当前的Openid用户操作
     * @return code:错误码
     * @return msg:错误消息
     */
	public function video_lists(Request $request)
	{
		if(!$request->isPost()) return False;
		$info=$request->param();
		$res = $this->video_list($info);
		return json($res);
	}
 /**
     * @title 获取单视频的点赞数和评论数
     * @description 获取单视频的点赞数和评论数
     * @author 凌杰
     * @url /talbum/video/get_counts
     * @method POST
     * @param name:videoid type:int require:1 default:'' other: desc:视频id
     * @param name:Openid type:string require:1 default:'' other: desc:为空表示登陆用户自己操作，否则表示当前的Openid用户操作
     * @return code:错误码
     * @return msg:错误消息
     * @return videoid:视频id
     * @return comments:评论数
     * @return points:点赞数
     */
    public function get_counts(Request $request){
        if(!$request->isPost()) return False;
        $info=$request->param();
        $res = $this->get_count($info);
        return json($res);
    }

        /**
     * @title 视频评论列表
     * @description 评论列表
     * @param name:videoid  type:int require:1  default:1  other: desc:图片id
     * @param name:page  type:int require:0  default:1  other: desc:页数
     * @param name:Openid type:string require:1 default:'' other: desc:为空表示登陆用户自己操作，否则表示当前的Openid用户操作
     * @param name:limit type:int require:0  default:10 other: desc:limit
     * @author 凌杰
     * @url /talbum/video/comment
     * @method POST
     * @return code:错误码
     * @return msg:错误消息
     * @return image:错误消息@
     * @image Picspath:图片路劲
     */
    public function comment(Request $request)
    {
        if(!$request->isPost()) return False;
        $info=$request->param();
       // $info['imagefile']=$request->file('imagefile');
        $res = $this->comment_list($info);
        return json($res);
    }


      /**
    * @title 增加评论
    * @description 增加评论
    * @author 凌杰
    * @url /talbum/video/add_comment
    * @method POST
    * @param name:videoid type:id require:0 default:"" other: desc:视频id
    * @param name:Openid type:string require:1 default:'' other: desc:为空表示登陆用户自己操作，否则表示当前的Openid用户操作
    * @param name:content type:string require:1 default:'' other: desc:评论内容
    * @param name:Replayid type:string require:1 default:'' other: desc:被评论人id    
    * @return code:错误码
    * @return msg:错误消息
    */
    public function add_comment(Request $request){
        $info=$request->param();
        $res = $this->comments($info);
        return json($res);
    }

 /**
    * @title 点赞
    * @description 点赞和取消点赞
    * @author 凌杰
    * @url /talbum/Video/point
    * @method POST
    * @param name:videoid type:int require:1 default:"" other: desc:视频id
    * @param name:Openid type:string require:1 default:'' other: desc:为空表示登陆用户自己操作，否则表示当前的Openid用户操作
    * @return code:错误码
    * @return msg:错误消息
    */
    public function point(Request $request){
        $info=$request->param();
        $res = $this->add_points($info);
        return json($res);
    }


	public function test(Request $request){

        echo '<!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
    <form action="/talbum/video/insert_video" enctype="multipart/form-data" method="post">
    <input type="text" name="videoname" value="name"> <br>
    <input type="text" name="Hits" value="10"> <br>
    <input type="text" name="describe" value="describe"/> <br>
    <input type="text" name="permissions" value="1"/> <br>
    <input type="text" name="videoregion" value="albumregion"/> <br>
    <input type="text" name="describe" value="describe"/> <br>
        <input type="file" name="cover" /> <br>
        <input type="file" name="video" /> <br>
        <input type="submit" value="上传" />
    </form>

    </body>
    </html>';

    }

}